package com.example.huangyuchen.advance.training.camp.week02.netty.inbound;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.experimental.FieldDefaults;

import java.util.List;

/**
 * @author YuChen Huang
 * @date 2022/1/22 22:32
 */
@FieldDefaults(level = AccessLevel.PRIVATE)
@AllArgsConstructor
public class CustomHttpInboundInitializer extends ChannelInitializer<SocketChannel> {

    List<String> proxyServer;

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {

        final ChannelPipeline pipeline = ch.pipeline();

        pipeline.addLast(new HttpServerCodec());
        pipeline.addLast(new HttpObjectAggregator(1024 * 1024));
        pipeline.addLast(new CustomHttpInboundHandler());

    }
}
